package com.wyw.base.comm;

import java.util.Map;

import org.springframework.http.HttpEntity;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wyw.core.secu.dto.UserDetailInfo;
import com.wyw.core.util.tag.impl.MenuReadonlyTag;

@Controller 
public class HomePage {
	@RequestMapping(value = "/home.biz",method=RequestMethod.GET)//
	public String sayHelloa(Model model){
		System.out.println("首页");
		return "home";
	}
	
	@RequestMapping(value = "/setUserMenuStatu.biz",method=RequestMethod.GET)//
	@ResponseBody
	public String setUserMenuStatu(@RequestParam String menuId,@RequestParam boolean statuFlag){
		Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	   	UserDetailInfo userDetails=(UserDetailInfo)principal;
	   	MenuReadonlyTag menuReadonlyTag =	userDetails.getMenu();
	   	MenuReadonlyTag menuReadonlyTagCh=(MenuReadonlyTag)menuReadonlyTag.getChildById(menuId);
	   	if(menuReadonlyTagCh !=null){
	   		menuReadonlyTagCh.setOpen(statuFlag);
	   	}
		// System.out.println("menuId d:"+menuId);
		 
		 
		return null;
	}
	
	@RequestMapping(value = "/setUserMenuStatu1.biz",method=RequestMethod.POST)//
	@ResponseBody
	public String setUserMenuStatu1(HttpEntity<String>  menuId){
		//@RequestParam("menuId") String menuId,@RequestParam("statuFlag") String statuFlag
		//Map requestMap =request.getParameterMap();
		System.out.println("menuId:"+menuId);
		return "ok";
	}
	
	 
	
	@RequestMapping(value = "/setUserMenuStatu2.biz",method=RequestMethod.POST)//
	@ResponseBody
	public String setUserMenuStatu2(Model model,Map map,ModelMap modelMap){
		//@RequestParam("menuId") String menuId,@RequestParam("statuFlag") String statuFlag
		//Map requestMap =request.getParameterMap();
		System.out.println("menuId:"+modelMap.get("menuId"));
		return "ok";
	}
}
